<?php


namespace app\index\server;


class BaseService
{
    /**
     * 返回用户所有父类id
     * @param int $id   用户id
     * @param string $usPid  用户父类id
     * @return array 所有父类id
     */
    public function getFatherId($id, $usPid = 'us_pid')
    {
        $pid = model('user')->where('id', $id)->value($usPid);
        $fatherId = $pid;
        if ($fatherId == 0) {
            $father = [];
        }
        while (!$fatherId == 0) {
            $fatherId = model('user')->where('id', $fatherId)->value($usPid);
            $father[] = $fatherId;
        }
        array_unshift($father, $pid);
        if (end($father) == 0) {
            array_pop($father);
        }
        return ['code'=>1 ,'data'=>$father];
    }

}